using System.Collections.Generic;

namespace PcrDataAnalysis
{
	public class MergedHRMCurve : HRMCurve
	{
		protected IHRMCurve mHRMCurve1;

		protected IHRMCurve mHRMCurve2;

		protected double mBeforeMergedDistance;

		public IHRMCurve HRMCurve2
		{
			get
			{
				return mHRMCurve2;
			}
			set
			{
				mHRMCurve2 = value;
			}
		}

		public IHRMCurve HRMCurve1
		{
			get
			{
				return mHRMCurve1;
			}
			set
			{
				mHRMCurve1 = value;
			}
		}

		public double BeforeMergedDistance
		{
			get
			{
				return mBeforeMergedDistance;
			}
		}

		public override int GetCurveCount()
		{
			return mHRMCurve1.GetCurveCount() + mHRMCurve2.GetCurveCount();
		}

		public MergedHRMCurve(IHRMCurve hrmCurve1, IHRMCurve hrmCurve2, double beforeMergedDistance)
		{
			mHRMCurve1 = hrmCurve1;
			mHRMCurve2 = hrmCurve2;
			mBeforeMergedDistance = beforeMergedDistance;
			mDistanceDictionary = new Dictionary<IHRMCurve, double>();
		}

		protected override double Calculate(IHRMCurve hrmCurve)
		{
			if (hrmCurve.Equals(this))
			{
				return 0.0;
			}
			bool isCurveExisted;
			double num = mHRMCurve1.CalculateDistance(hrmCurve, out isCurveExisted);
			double num2 = mHRMCurve2.CalculateDistance(hrmCurve, out isCurveExisted);
			int curveCount = mHRMCurve1.GetCurveCount();
			int curveCount2 = mHRMCurve2.GetCurveCount();
			return num * (double)curveCount / (double)curveCount2 + num2 * (double)curveCount2 / (double)curveCount;
		}
	}
}
